// vue.config.js
const path = require("path");
const resolve = dir => {
  return path.join(__dirname, dir);
};
const IS_PROD = process.env.NODE_ENV === "production";
module.exports = {
  // 基本路径
  publicPath: "/",

  outputDir: "dist",

  // eslint-loader 是否在保存的时候检查

  runtimeCompiler: false,
  productionSourceMap: false,
  chainWebpack: config => {
    config.resolve.symlinks(true);
    //生产环境下, 开发不起作用
    if (IS_PROD) {
    }
    // 添加别名
    config.resolve.alias
      .set("@", resolve("src"))
      .set("@img", resolve("src/assets/imgs"))
      .set("_j", resolve("src/assets/js"))
      .set("@c", resolve("src/components"));
  },
  css: {
    extract: false
  },
  devServer: {
    host: "0.0.0.0",
    port: 8080,
    https: false,
    hotOnly: true,
    hot: true,
    compress: false, // 开启压缩
    overlay: {
      warnings: false,
      errors: true
    },
    disableHostCheck: true,
    proxy: {
      "/api": {
        target: "http://localhost:3000",
        changeOrigin: true,
        crossOrigin: true,
        withCredentials: true
      }
    }
  }
};
